var SparkMD5 = require('spark-md5/spark-md5.min')

const UploadMd5 = (file) => {
  return _uploadFile(file)
}

function _uploadFile (file) {
  return new Promise((resolve, reject) => {
    var fileReader = new FileReader()
    var spark = new SparkMD5.ArrayBuffer()
    fileReader.readAsArrayBuffer(file)
    fileReader.onload = function (e) {
      spark.append(e.target.result)
      var md5 = spark.end()
      resolve({
        mds: md5
      })
    }
  })
}

export {
  UploadMd5
}
